/**
 * 进行牌面的复位操作
 */
function draw_play_paireset(){
    cc.log("Pai_rest");
    //遍历禁拖墩；上面是否还有牌？,没有牌则删除这个禁拖墩
    for( var i = 0 ; i < DUN_NO_TUO.length ; i++ ){
        if( DUN_PS[ DUN_NO_TUO[i] ] <= 0 ){
            PL_Room_Play.yidong_pai( (DUN_NO_TUO[i]+1) );
            DUN_NO_TUO.splice(i,1);
        }
    }
    //进行一次所有墩上牌数的检查；如果牌数为0；则调用移动牌的操作::这里使用系统配置的墩数
    for ( var i = 0 ; i <= DUNSHU-1 ; i++ ){
        if( DUN_PS[i] <= 0 ){
            PL_Room_Play.yidong_pai( (i+1) );
        }
    }
    //进行一次所有牌墩上的数的检查；根据数量进行牌的全部顺序以及height高（y轴）的重排
    cc.log( PL_Room_Play.PPP_pai );
    for( var i = 0 ; i < DUN_PS.length ; i++ ){
        //如果该墩上还有牌的情况下
        if( DUN_PS[i] > 0 && DUN_PS[i] <= 3 ){
            //查找所有属于这墩的牌；
            for( var m = 1 ; m <  PL_Room_Play.PPP_pai.length ; m++ ){
                if( (PL_Room_Play.PPP_pai[m].dijidun - 1) == i ){
                    var temp_dijige = PL_Room_Play.PPP_pai[m].dijige;
                    switch ( temp_dijige ){
                        case 0://当前是该墩上的第0个牌；不需要做操作
                            break;
                        case 1://当前是该墩上的第1个牌；（如果该墩第0个牌存在牌，则需要进行掉落1个牌的距离）
                            if( find_dun_dijige_is_int((i+1), 0 ) == false ){
                                PL_Room_Play.PPP_pai[m].dijige = 0;//将第几个设置为0
                                PL_Room_Play.PPP_pai[m].default_Zorder = 4;
                                PL_Room_Play.PPP_pai[m].setLocalZOrder(4);
                                PL_Room_Play.PPP_pai[m].y      = PAI_BOTOTM;
                                PL_Room_Play.PPP_pai[m].jilu_y = PAI_BOTOTM;
                            }
                            break;
                        case 2:
                            var this_index_0 = find_dun_dijige_is_int((i+1), 0 );
                            var this_index_1 = find_dun_dijige_is_int((i+1), 1 );
                            if( this_index_0 == false && this_index_1 == false ){
                                PL_Room_Play.PPP_pai[m].dijige = 0;//如果0跟1都不存在，那么我就是0
                                PL_Room_Play.PPP_pai[m].default_Zorder = 4;
                                PL_Room_Play.PPP_pai[m].setLocalZOrder(4);
                                PL_Room_Play.PPP_pai[m].y      = PAI_BOTOTM;
                                PL_Room_Play.PPP_pai[m].jilu_y = PAI_BOTOTM;
                            }
                            if( this_index_0 == true && this_index_1 == false ){
                                PL_Room_Play.PPP_pai[m].dijige = 1;//如果0存在，1不存在；那我就是1
                                PL_Room_Play.PPP_pai[m].default_Zorder = 3;
                                PL_Room_Play.PPP_pai[m].setLocalZOrder(3);
                                PL_Room_Play.PPP_pai[m].y      = PAI_BOTOTM + PAI_JIANJU;
                                PL_Room_Play.PPP_pai[m].jilu_y = PAI_BOTOTM + PAI_JIANJU;
                            }
                            if( this_index_0 == false && this_index_1 == true ){
                                PL_Room_Play.PPP_pai[m].dijige = 1;//如果0不存在，1存在，那我也是1；因为通过上面的，0不存在的情况下，1会自动掉下去
                                PL_Room_Play.PPP_pai[m].default_Zorder = 3;
                                PL_Room_Play.PPP_pai[m].setLocalZOrder(3);
                                PL_Room_Play.PPP_pai[m].y      = PAI_BOTOTM + PAI_JIANJU;
                                PL_Room_Play.PPP_pai[m].jilu_y = PAI_BOTOTM + PAI_JIANJU;
                            }
                            break;
                        case 3:
                            var this_index_0 = find_dun_dijige_is_int((i+1), 0 );
                            var this_index_1 = find_dun_dijige_is_int((i+1), 1 );
                            var this_index_2 = find_dun_dijige_is_int((i+1), 2 );
                            if( this_index_0 == false && this_index_1 == false && this_index_2 == false ){
                                PL_Room_Play.PPP_pai[m].dijige = 0;//如果下面3个牌都不存在，那我就是0
                                PL_Room_Play.PPP_pai[m].default_Zorder = 4;
                                PL_Room_Play.PPP_pai[m].setLocalZOrder(4);
                                PL_Room_Play.PPP_pai[m].y      = PAI_BOTOTM;
                                PL_Room_Play.PPP_pai[m].jilu_y = PAI_BOTOTM;
                            }
                            if( this_index_0 == true && this_index_1 == true && this_index_2 == false ){
                                PL_Room_Play.PPP_pai[m].dijige = 2;//如果底下2个存在，第三个不存在；那我就是第三个（2）
                                PL_Room_Play.PPP_pai[m].default_Zorder = 2;
                                PL_Room_Play.PPP_pai[m].setLocalZOrder(2);
                                PL_Room_Play.PPP_pai[m].y      = PAI_BOTOTM + PAI_JIANJU * 2;
                                PL_Room_Play.PPP_pai[m].jilu_y = PAI_BOTOTM + PAI_JIANJU * 2;
                            }
                            if( this_index_0 == true && this_index_1 == false && this_index_2 == false ){
                                PL_Room_Play.PPP_pai[m].dijige = 1;//如果底下一个存在，2，跟3都不存在；那我就是第二个（1）
                                PL_Room_Play.PPP_pai[m].default_Zorder = 3;
                                PL_Room_Play.PPP_pai[m].setLocalZOrder(3);
                                PL_Room_Play.PPP_pai[m].y      = PAI_BOTOTM + PAI_JIANJU;
                                PL_Room_Play.PPP_pai[m].jilu_y = PAI_BOTOTM + PAI_JIANJU;
                            }
                            if( this_index_0 == true && this_index_1 == false && this_index_2 == true ){
                                PL_Room_Play.PPP_pai[m].dijige = 1;//如果1跟3存在；那我就是第二个
                                PL_Room_Play.PPP_pai[m].default_Zorder = 3;
                                PL_Room_Play.PPP_pai[m].setLocalZOrder(3);
                                PL_Room_Play.PPP_pai[m].y      = PAI_BOTOTM + PAI_JIANJU;
                                PL_Room_Play.PPP_pai[m].jilu_y = PAI_BOTOTM + PAI_JIANJU;
                            }
                            if( this_index_0 == false && this_index_1 == true && this_index_2 == true ){
                                PL_Room_Play.PPP_pai[m].dijige = 0;//如果1不存在，2跟3存在，那我就是第一个
                                PL_Room_Play.PPP_pai[m].default_Zorder = 4;
                                PL_Room_Play.PPP_pai[m].setLocalZOrder(4);
                                PL_Room_Play.PPP_pai[m].y      = PAI_BOTOTM;
                                PL_Room_Play.PPP_pai[m].jilu_y = PAI_BOTOTM;
                            }
                            if( this_index_0 == false && this_index_1 == false && this_index_2 == true ){
                                PL_Room_Play.PPP_pai[m].dijige = 0;//如果1跟2不存在，3存在；那我就是第1个
                                PL_Room_Play.PPP_pai[m].default_Zorder = 4;
                                PL_Room_Play.PPP_pai[m].setLocalZOrder(4);
                                PL_Room_Play.PPP_pai[m].y      = PAI_BOTOTM;
                                PL_Room_Play.PPP_pai[m].jilu_y = PAI_BOTOTM;
                            }
                            break;
                    }
                }
            }
        }
    }
    //进行一次全局牌的层次索引重设
    //PL_Room_Play.allPaiSort();
}
/**
 * 查询某一墩上面，某一个是否还存在？
 * @param dijidun  1-
 * @param dijige   0-
 */
function find_dun_dijige_is_int( dijidun , dijige ){
    var find = false;
    for( var i = 1 ; i <  PL_Room_Play.PPP_pai.length ; i++ ){
        if( PL_Room_Play.PPP_pai[i].dijidun == dijidun && PL_Room_Play.PPP_pai[i].dijige == dijige ){
            find = true;
        }
    }
    return find;
}